package cn.mall;

import cn.mall.auth.interceptor.AuthInterceptor;
import cn.mall.user.interceptor.LoginInterceptor;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.web.servlet.ServletComponentScan;
import org.springframework.scheduling.annotation.EnableScheduling;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

/**
 * Hello world!
 */
@SpringBootApplication
@MapperScan("cn.mall.*.mapper")                     // 扫描 mapper 包
@ServletComponentScan("cn.mall.auth.listener")    // 扫描监听器
@EnableScheduling                                  // 启用定时任务
public class WeiboMallStart implements WebMvcConfigurer{

    @Autowired
    private AuthInterceptor authInterceptor;

    public static void main(String[] args) {
        SpringApplication.run(WeiboMallStart.class, args);
    }

    // 重写添加拦截器方法
    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        registry.addInterceptor(authInterceptor)
                .addPathPatterns("/**")   //拦截所有
                .excludePathPatterns("/auth/**","/shop/**","/order/complete/**","/order/completeOid/**","/order/verification","/order/refreshByOid/**",
                        "/goods/**","/order/uid","/user/logout","/user/login","/order/receivingById/**","/order/receiving/**",
                        "/order/refund/**","/order/refresh/**","/customerService/**","/login","/app/download","/poster/**");  //放行资源
    }
//    "/order"
//    "/order/addOrder","/order/addLotOrder"

}
